<?php

/**
 * Oferta form base class.
 *
 * @method Oferta getObject() Returns the current form's model object
 *
 * @package    MercaderDigital
 * @subpackage form
 * @author     Germán Figueredo
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseOfertaForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'ID_Producto'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Producto'), 'add_empty' => false)),
      'ID_Proveedor'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Proveedor'), 'add_empty' => false)),
      'FechaRegistro'   => new sfWidgetFormDate(),
      'SemanasVigencia' => new sfWidgetFormInputText(),
      'Precio'          => new sfWidgetFormInputText(),
      'fechaEvento'     => new sfWidgetFormInputText(),
      'Evento'          => new sfWidgetFormInputText(),
      'id_user_ev'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('UsuarioEvento'), 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'ID_Producto'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Producto'))),
      'ID_Proveedor'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Proveedor'))),
      'FechaRegistro'   => new sfValidatorDate(),
      'SemanasVigencia' => new sfValidatorInteger(),
      'Precio'          => new sfValidatorNumber(),
      'fechaEvento'     => new sfValidatorPass(array('required' => false)),
      'Evento'          => new sfValidatorString(array('max_length' => 20, 'required' => false)),
      'id_user_ev'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('UsuarioEvento'), 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('oferta[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Oferta';
  }

}
